home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_10
/
saks
/
comq6.h
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-08
|
1KB
|
64 lines
Listing 5 - class and inline member function definitions for a generic
queue of common *
//
// comq6.h - generic queue of common *
// with an iterator class
//
#include "common.h"
class comq
{
private:
struct cell
{
cell(const common &e, cell *p);
~cell();
cell *next;
common *element;
};
cell *first, *last;
public:
comq();
~comq();
void append(const common &e);
void clear();
int remove(common &e);
class iterator;
friend class iterator;
class iterator
{
public:
iterator(comq &q);
common *next();
private:
cell *pc;
};
};
inline comq::cell::cell(const common &e, cell *p)
: element(e.dup()), next(p)
{
}
inline comq::cell::~cell()
{
delete element;
}
inline comq::iterator::iterator(comq &q)
: pc(q.first)
{
}
inline comq::comq() : first(0), last(0)
{
}
inline comq::~comq()
{
clear();
}